import React, { Component } from 'react'
import axios from "axios";

export default class App extends Component {

   getStudentInfo = async()=>{
    // Access-Control-Allow-Origin跨域了,因为同源策略的限制
    const {data} = await axios.get('http://localhost:3000/api1/students')
    console.log(data);
  }

  getCarInfo = async()=>{
    const {data} = await axios.get('http://localhost:3000/api2/cars')
    console.log(data);
  }
  render() {
    return (
      <div>
        <button onClick={this.getStudentInfo}>点我发送ajax请求获取学生信息</button>
        <button onClick={this.getCarInfo}>点我发送ajax请求获取汽车信息</button>
      </div>
    )
  }
}
